<?php

 /**
  * @package JooS
  * @subpackage Syntax_PHPackager
  */

  require_once "JooS/Syntax/Complex/Transition.php";

 /**
  * Function ::= ( Name, { ".", Name } ), "(", List, ")" { "->", Name , "(", List, ")" };
  */
  class JooS_Syntax_PHPackager_Function_Call extends JooS_Syntax_Complex_Transition {
    /**
     * @return string
     */
    public function compile() {
      $ret = parent::compile();
      if ($ret !== false) {
        require_once "JooS/Syntax/Compiler.php";

        $ret = JooS_Syntax_Compiler::isReservedWord($this->getParsedValue(0)) ? false : "\$this->_call->" . $ret;
      }
      return $ret;
    }

    /**
     * @return JooS_Syntax_Complex_Concatenate
     */
    public function createRule() {
      $parser = $this->getParser();
      
      return $parser->createSyntax("Complex_Concatenate", array(
        $parser->createSyntax("Common_Name"),
        $parser->createSyntax("Common_Whitespace"),
        $parser->createSyntax("Simple_Symbol", "("),
        $parser->createSyntax("Common_Whitespace"),
        $parser->createSyntax("PHPackager_List"),
        $parser->createSyntax("Common_Whitespace"),
        $parser->createSyntax("Simple_Symbol", ")"),
        $parser->createSyntax("Complex_Repetition", $parser->createSyntax("Complex_Concatenate", array(
          $parser->createSyntax("Common_Whitespace"),
          $parser->createSyntax("Simple_Symbol", "->"),
          $parser->createSyntax("Common_Whitespace"),
          $parser->createSyntax("Common_Name"),
          $parser->createSyntax("Common_Whitespace"),
          $parser->createSyntax("Simple_Symbol", "("),
          $parser->createSyntax("Common_Whitespace"),
          $parser->createSyntax("PHPackager_List"),
          $parser->createSyntax("Common_Whitespace"),
          $parser->createSyntax("Simple_Symbol", ")"),
        )))
      ));
    }
  }
